<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML>
<html>
  <head> 
	<%@ include file="/platform/style.jsp"%>
	<style>
		.state0{color:red}
	</style>
	<script>
	function query(){
		$w.execForm({pageNum:1})
	}

    function addUser(){
        $w.openDialog({url:ctx+'/user/UserPage@show.page',title:"添加客户资料",w:700,h:450,maximized:true,afterClose:function(re){
            if(re){
                query();
            }
        }});
    }

	function editUser(uid){
		$w.openDialog({url:ctx+'/user/UserPage@show.page?bean.id='+uid,title:"编辑客户资料",w:700,h:450,maximized:true,afterClose:function(re){
			if(re){
				query();
			}
		}});
	}

	function editUserPassword(uid) {
        var password = prompt("请输入新的密码: ");
        if(password != null) {
            if ((/^\w{6,20}$/).test(password)) {
                if(confirm("确认要修改该用户的密码吗?")) {
                    $w.doUrl(ctx+"/user/UserPage@editUserPassword.page?bean.id="+uid+"&bean.password="+password,{},function(json){
                        window.parent.$w.correctMsg("修改密码成功");
                        query();
                    });
                }
			}else {
                alert("请输入6-20位的密码!");
			}
		}

    }
	
	function enabledUser(uid){
		window.parent.$w.confirmMsg("确定启用改用户？", function(r){
			if(r){
				$w.doUrl(ctx+"/user/UserPage@enabledUser.page?bean.id="+uid,{},function(json){
					query();
				})
			}
		})
	}
	
	function disabledUser(uid){
		window.parent.$w.confirmMsg("确定禁用改用户？", function(r){
			if(r){
				$w.doUrl(ctx+"/user/UserPage@disabledUser.page?bean.id="+uid,{},function(json){
					query();
				})
			}
		})
	}
	function delUser(uid){
		window.parent.$w.confirmMsg("确定删除用户？", function(r){
			if(r){
				$w.doUrl(ctx+"/user/UserPage@del.page?bean.id="+uid,{},function(json){
					query();
				})
			}
		})
	}
	</script>
  </head>
  
  <body class="easyui-layout">
	<div data-options="region:'center'" class="bodybg">
		<!-- 查询区域 -->
		<form id="queryForm" action="/user/UserPage.page" method="post">
		<w:hidden bind="pageNum"/>
		<w:hidden bind="pageSize_"/>
		<div class="easyui-panel ui-queryBar" border="false" data-options="doSize:false">
			<table cellpadding="0" cellspacing="0" style="margin-top:5px">
				<tr>
					<td width="60" align="right">手机号：</td><td><w:text bind="bean.phone" style="width:120px;"/></td>
					<td width="60" align="right">联系人：</td><td><w:text bind="bean.contacts" style="width:120px;"/></td>
					<td width="60" align="right">单位：</td><td><w:text bind="bean.comname" style="width:120px;"/></td>
					<td width="80" align="right">来源：</td><td><select name="bean.source"><option value="">全部</option><w:option bind="bean.source" value="1">PC端</w:option><w:option bind="bean.source" value="2">微信</w:option><w:option bind="bean.source" value="3">后台</w:option></select></td>
					<td>
						&nbsp;<a href="javascript:;" class="easyui-linkbutton" iconCls="icon_search" onclick="query()">查询</a>
					</td>
				</tr>
			</table>
		</div>

		<div class="panel"><div class="easyui-panel ui-toolBar panel-body panel-body-noheader panel-body-noborder" border="false" data-options="doSize:false" title="">
			<a href="#" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon_add" plain="true" onclick="addUser()" group="" id=""><span style="position: relative;top: -3px;" class="l-btn-left"><span class="l-btn-text icon_add l-btn-icon-left">添加客户</span></span></a>
		</div></div>
		
		<div class="ui_line" style="margin-top:10px"></div>
		<!-- 数据列表区域 -->
			<table class="ui-table" width="100%" cellpadding="1" cellspacing="1" data-options="showPage:true,
																								pageNum:<w:write bind="pageNum"/>,
																								pageSize:<w:write bind="pageSize_"/>,
																								total:<w:write bind="pagination.totalCount"/>,form:'queryForm'">
				<thead>
					<tr class="ui_th">
						<td width="40">ID</td>
						<td width="100">账号</td>
						<td width="100">昵称</td>
						<td width="100">客户等级</td>
						<td>单位名称</td>
						<td width="100">企业类型</td>
						<td width="50">来源</td>
						<td width="70">联系人</td>
						<td width="100">手机号</td>
						<td width="80">审核状态</td>
						<td width="80">启用状态</td>
						<td width="220" align="center">操作</td>
					</tr>
				</thead>
				<tbody>
				<w:iterate id="info" bind="resultList_">
					<tr class="ui_td">
						<td><w:write bind="#info.id"/></td>
						<td><w:write bind="#info.loginname"/></td>
						<td><w:write bind="#info.nickname"/></td>
						<td><w:write bind="#info.grade" dict="UserGrade"/></td>
						<td><w:write bind="#info.comname"/></td>
						<td><w:write bind="#info.comtype" dict="CompanyType"/></td>
						<td><w:write bind="#info.source" defaultVal="PC端" format="[未知,PC端,微信,后台]"/></td>
						<td><w:write bind="#info.contacts"/></td>
						<td><w:write bind="#info.phone"/></td>
						<td><w:write bind="#info.authstate" format="[未认证,待审核,已通过,未通过]"/></td>
						<td><font class="state<w:write bind="#info.state"/>"><w:write bind="#info.state" format="[已禁用,已启用]"/></font></td>
						<td align="center">
							<a href="javascript:void(0);" class="ui_btn marginR8" onclick="editUserPassword(<w:write bind="#info.id"/>)">改密</a>
							<a href="javascript:void(0);" class="ui_btn marginR8" onclick="editUser(<w:write bind="#info.id"/>)">编辑</a><w:equal bind="#info.state" value="0"><a href="javascript:void(0);" class="ui_btn marginR8" onclick="enabledUser(<w:write bind="#info.id"/>)">启用</a></w:equal><w:equal bind="#info.state" value="1"><a href="javascript:void(0);" class="ui_btn marginR8" onclick="disabledUser(<w:write bind="#info.id"/>)">禁用</a></w:equal><a href="javascript:void(0);" class="ui_btn" onclick="delUser(<w:write bind="#info.id"/>)">删除</a>
						</td>
					</tr>
				</w:iterate>
				</tbody>
			</table>
		</form>
	</div>
  </body>
</html>
